﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace _04DivideFactorials
{
    class _04DivideFactorials
    {
        static void Main(string[] args)
        {
            top:
            Console.Write("Calculating N!/K! such that 1<K<N . \nEnter value for N:");
            string strN = Console.ReadLine();
            BigInteger valueN = BigInteger.Parse(strN);
            Console.Write("Enter value for K:");
            string strK = Console.ReadLine();
            BigInteger valueK = BigInteger.Parse(strK);
            if (valueK > valueN || valueK < 1)
            {
                Console.WriteLine("Condition not met 1<K<N !!!");
                Console.WriteLine("Enter again:");
                goto top; //Знам че не се пропръчва употребата на goto но за сега това е начина който знам.
            }
            else if (valueK <= valueN && valueK > 1)
            {
                Console.WriteLine("You entered {0} for N and {1} for K.", valueN, valueK);
                BigInteger factorialN = 1;
                BigInteger factorialK = 1;
                while (valueN > 0)
                {
                    factorialN = factorialN * valueN;
                    valueN--;
                }
                Console.WriteLine("N! = {0}", factorialN);
                while (valueK > 0)
                {
                    factorialK = factorialK * valueK;
                    valueK--;
                }
                Console.WriteLine("K! = {0}", factorialK);
                Console.WriteLine("N!/K! = " + factorialN/factorialK);
                Console.ReadLine();
            }
        }
    }
}
